package com.duan.rabbitmq.direct;

import com.duan.rabbitmq.utils.RabbitMqUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;

/**
 * @author db
 * @version 1.0
 * @description Provider
 * @since 2023/11/28
 */
public class Provider {
    public static void main(String[] args) throws IOException {
        // 建立连接
        Connection connection = RabbitMqUtil.getConnection();
        Channel channel = connection.createChannel();

        channel.exchangeDeclare("logs_direct","direct");

        String routingKey = "error";
        channel.basicPublish("logs_direct",routingKey,null,("这是direct模型发布的基于route key: ["+routingKey+"] 发送的消息").getBytes());

        RabbitMqUtil.closeConnectionAndChannel(channel,connection);
    }
}
